package bankowosc.polaczenie;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import bankowosc.dane.Klient;

public class KlientBD {

	public Klient zaloguj(polacz p, int login, String haslo) {
		Klient klient;
               
              
                       
		Statement stmt = p.getStmt();
               
		String komenda = "select * from klient where id_klienta="+login+" and haslo='"+haslo+"'";
		try {
			ResultSet rs = stmt.executeQuery(komenda);
			if(rs.next()) {
				klient = new Klient(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),
						rs.getString(7),rs.getString(8),rs.getString(9),rs.getString(10),rs.getString(11),rs.getString(12),
						rs.getString(13),rs.getString(14),rs.getString(15),rs.getString(16),rs.getString(17),rs.getString(18),
						rs.getString(19),rs.getInt(20),rs.getInt(21),rs.getString(22));
				rs.close();
				return klient;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
